import java.util.*;

class Deck{

	Card[] deck;

	Random x;

	Deck() {
		
		int a = 2,b = 1,z = 0;
		
		deck = new Card[52];
		
		for(int i = 1; i<=4; i++)
		{
			for(int j = 2; j<15; j++)
			{
				deck[z] = new Card(j,i);
				z++;
			}
		}
		
		x = new Random();
	
		int k = x.nextInt(52);
		
		a = 0;
		b = 0;
		
		for( int i = 0; i<52; i++ ) {
			a = deck[i].card[0];
			b = deck[i].card[1];
		
			deck[i].card[0] = deck[k].card[0];
			deck[i].card[1] = deck[k].card[1];
		
			deck[k].card[0] = a;
			deck[k].card[1] = b;
			
			k = x.nextInt(52);
		}
	}
	
	Card[] returnDeck(){
		return deck;
	}
	
	void showDeck() {
		for( int z=0; z<52; z++ ) {
			
			if( z%13 == 0 && z > 0) {
				System.out.println("\n");
			}
			
			System.out.print(deck[z].card[0] +" "+ deck[z].card[1]+ "\t" );		
		}
	System.out.println("\n");	
	}
	
	Card getCard(){
		
		Card card = new Card(0,0);
		
		int a = deck[0].card[0];
		int b = deck[0].card[1];
		
		deck[0].card[0] = 0;
		deck[0].card[1] = 0;
		
		card.card[0] = a;
		card.card[1] = b;
		
		int z = 0;
		while( z<51 )
		{	
		
		if( deck[z+1].card[0] != 0 )
			{
			a=0;
			b=0;
	
			a = deck[z].card[0];
			b = deck[z].card[1];

			deck[z].card[0] = deck[z+1].card[0];
			deck[z].card[1] = deck[z+1].card[1];

			deck[z+1].card[0] = a;
			deck[z+1].card[1] = b;
	
			z++;
			}
		else
			break;
		}
		
		return card;
	}
}
